﻿Public Class frmShowRapporte

    Private Sub frmShowRapporte_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        frmShowAufgaben.Show()
    End Sub

    Private Sub frmShowRapporte_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: Diese Codezeile lädt Daten in die Tabelle "DbShowRapporte3.Rapporte". Sie können sie bei Bedarf verschieben oder entfernen.
        Me.RapporteTableAdapter.Fill(Me.DbShowRapporte3.Rapporte)

        Dim aufgabe As Projekt = Projekt.GetObject()

        Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=|DataDirectory|\db.accdb")

        Dim cmd As New OleDb.OleDbCommand("Select * From Rapporte Where FK_Aufgabe = " + aufgabe.aufgabenrowId + ";", conn)

        Dim da As New OleDb.OleDbDataAdapter(cmd)

        Dim ds As New DataSet

        conn.Open()

        da.Fill(ds)

        conn.Close()

        gvRapporte.DataSource = ds.Tables(0).DefaultView

    End Sub

    Private Sub gvRapporte_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvRapporte.CellClick
        If e.RowIndex >= 0 And e.ColumnIndex = gvRapporte.Columns("zlBearbeiten").Index Then
            Dim taskID As Int32 = CInt(gvRapporte(0, e.RowIndex).Value)
            'Dim idRow As String = gvAufgaben.Rows(taskID - 1).Cells(0).Value
            ' Rowid = idRow
            Dim eindeutiges_from As Projekt = Projekt.GetObject()
            eindeutiges_from.rapportrowId = taskID
            eindeutiges_from.rapportEdit = True
            Me.Hide()
            frmEditRapport.Show()
        End If
    End Sub

    Private Sub btnNewRapport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewRapport.Click
        Me.Hide()
        frmEditRapport.Show()
    End Sub
End Class